package com.quiz.bis.service;

import com.quiz.bis.domain.bo.QuestionBo;
import com.quiz.bis.domain.bo.QuestionExportBo;
import com.quiz.bis.domain.dto.QuestionDuplicateCheckDto;
import com.quiz.bis.domain.dto.QuestionDuplicateResult;
import com.quiz.bis.domain.model.Question;
import com.quiz.bis.domain.model.QuestionQuery;
import com.quiz.bis.domain.vo.QuestionDetailVo;
import com.quiz.bis.domain.vo.QuestionExportVo;
import com.quiz.bis.domain.vo.QuestionVo;
import com.quiz.common.core.domain.R;
import com.quiz.common.mybatis.core.page.PageQuery;
import com.quiz.common.mybatis.core.page.TableDataInfo;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;


/**
 * 题目服务层接口
 * @author ahuan
 */
public interface IQuestionService {
    /**
     * 新增题目
     * @param question 题目信息
     * @return 题目ID
     */
    R<Long> addQuestion(QuestionBo question);

    TableDataInfo<QuestionVo> selectPageQuestionList(QuestionQuery query, PageQuery page);

    TableDataInfo<QuestionDetailVo> fulltextSearch(String keyword, Long categoryId, PageQuery page);

    boolean deleteQuestionByIds(Long[] ids);

    QuestionDetailVo selectQuestionById(Long id);


    boolean updateQuestion(QuestionBo bo);

    /**
     * 导出题目列表
     *
     * @param query 查询条件
     * @return 题目列表按题型分组
     */
    List<QuestionExportVo> exportQuestionList(QuestionExportBo query);

    /**
     * 导出为PDF
     *
     * @param questions 题目列表
     * @param response 响应对象
     */
    void exportToPdf(List<QuestionExportVo> questions, HttpServletResponse response,
                     HttpServletRequest request, QuestionExportBo query);

    /**
     * 导出为Word
     *
     * @param questions 题目列表
     * @param response 响应对象
     */
    void exportToWord(List<QuestionExportVo> questions, HttpServletResponse response,
                      HttpServletRequest request, QuestionExportBo query);

    /**
     * 题目相似度搜索
     * @param questionId 题目ID
     * @param page      分页参数
     * @param threshold 相似度阈值
     * @return
     */
    TableDataInfo<QuestionDetailVo> querySimilarQuestions(Long questionId , PageQuery page, Double threshold);

    /**
     * 题目相似度搜索
     * @param questionHtml 题目富文本
     * @param page      分页参数
     * @param threshold 相似度阈值
     * @return
     */
    TableDataInfo<QuestionDetailVo> querySimilarQuestions(String questionHtml , PageQuery page, Double threshold);



    public List<QuestionDetailVo> findSimilarQuestions(Long questionId, int count);

    public List<QuestionDetailVo> findByKnowledgeDifferentDifficulty(Long questionId, Long typeId, Integer difficulty, int count);

    public List<QuestionDetailVo> findByDifficultyDifferentKnowledge(Long questionId, Long typeId, Integer difficulty, int count);

    public List<QuestionDetailVo> findRandomQuestions(Long typeId, int count);


    TableDataInfo<QuestionDetailVo> selectPageQuestionList2(QuestionQuery query, PageQuery page);

}